//
//  LSFMoyaProvider.swift
//  Exam-iOS
//
//  Created by lishengfeng on 2018/3/25.
//  Copyright © 2018年 李胜锋. All rights reserved.
//

import Foundation
import Moya
import Alamofire

class LSFMoyaProvider<Target: TargetType> {
    static func alamofireManager(_ timeoutInterval: TimeInterval = 5) -> SessionManager{
        let configuration = URLSessionConfiguration.default
        configuration.timeoutIntervalForRequest = timeoutInterval
        configuration.httpAdditionalHeaders = SessionManager.defaultHTTPHeaders
        
        return SessionManager(configuration: configuration)
    }
    
    static func provider(_ timeoutInterval: TimeInterval = 5) -> MoyaProvider<Target> {
        let manager = LSFMoyaProvider.alamofireManager(timeoutInterval)
        let result = MoyaProvider<Target>.init(manager: manager)
        return result
    }
}
